//package com.xiaozhu.filter;
//
//import com.xiaozhu.pojo.JwtProperties;
//import com.xiaozhu.utils.JwtUtils;
//import io.jsonwebtoken.Claims;
//import jakarta.servlet.*;
//import jakarta.servlet.annotation.WebFilter;
//import jakarta.servlet.http.HttpServletRequest;
//import jakarta.servlet.http.HttpServletResponse;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//
//import java.io.IOException;
//
///**
// * @author 朱慧军
// * @version 1.0
// */
//@Component
////@WebFilter(urlPatterns = "/*") // 开启过滤器
//@Slf4j
//public class MyFilter implements Filter {
//
////    @Autowired
////    private JwtProperties jwtProperties;
//
//
//    @Override
//    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
//
//        log.info("过滤器启动");
//
//        HttpServletRequest request = (HttpServletRequest) servletRequest;
//        HttpServletResponse response = (HttpServletResponse) servletResponse;
//
//        String uri = request.getRequestURI();
//
//        if (uri.endsWith("login")) {
//            filterChain.doFilter(request, response);
//            return;
//        }
//
//        if (uri.endsWith("logout")) {
//            filterChain.doFilter(request, response);
//            return;
//        }
//
//        String token = request.getHeader("token");
//        if (token == null) {
//            response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
//            return;
//        }
//
//        try {
//            Claims claims = JwtUtils.parseToken(jwtProperties.getSecretKey(), token);
//        } catch (Exception e) {
//            throw new RuntimeException(e);
//        }
//
//        filterChain.doFilter(request, response);
//
//    }
//}
